/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package nc.bs.mmpac.reqpickm.transfer.pubhandler;

import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;

import nc.bs.mmpac.reqpickm.transfer.task.DoneReqPickmHandler;
import nc.bs.mmpac.reqpickm.transfer.task.GetPickItemByDmopksHandler;
import nc.bs.mmpac.reqpickm.transfer.task.QueryTransBillListComfirmHandler;
import nc.bs.mmpac.reqpickm.transfer.task.SaveReqPickmHandler;
import nc.bs.mmpac.reqpickm.transfer.task.SearchMatHandler;
import nc.bs.mmpac.reqpickm.transfer.task.ToOtherInTransBillHandler;
import nc.bs.mmpac.reqpickm.transfer.task.TransConfirmHandler;
import nc.bs.mmpac.reqpickm.transfer.truck.GetEmptyCarHandler;
import nc.bs.mmpac.reqpickm.transfer.truck.SendEmptyCarHandler;
import nc.bs.mmpac.reqpickm.transfer.truck.SendFullCarHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.GetTransBillInfoHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.MatCheckHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.QueryReqPickmHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.QueryTransBillHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.QueryTransBillListHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.SaveTransBillHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.SendMatHandler;
import nc.bs.mmpac.reqpickm.transfer.warehouse.ToOtherOutTransBillHandler;

public class HandlerFactory {
	private Map<String, Class<?>> handlerMap = new HashMap();

	public HandlerFactory() {
		init();
	}

	public IWorkTaskHandler getHandler(String key) {
		if (!(this.handlerMap.containsKey(key))) {
			return null;
		}
		IWorkTaskHandler handler = null;
		Class cls = (Class) this.handlerMap.get(key);
		try {
			Constructor[] constr = cls.getConstructors();
			if ((constr == null) || (constr.length == 0)) {
				return null;
			}
			handler = (IWorkTaskHandler) constr[0].newInstance(new Object[0]);
		} catch (Exception localException) {
		}

		return handler;
	}

	public void init() {
		this.handlerMap.put("save", SaveReqPickmHandler.class);
		this.handlerMap.put("done", DoneReqPickmHandler.class);
		this.handlerMap.put("confirm", TransConfirmHandler.class);
		this.handlerMap.put("sendMat", SendMatHandler.class);
		this.handlerMap.put("searchMat", SearchMatHandler.class);
		this.handlerMap.put("matCheck", MatCheckHandler.class);
		this.handlerMap.put("saveTrans", SaveTransBillHandler.class);
		this.handlerMap.put("queryReqPickm", QueryReqPickmHandler.class);
		this.handlerMap.put("connect", ConnectTestHandler.class);
		this.handlerMap.put("searchOrg", SearchOrgHandler.class);
		this.handlerMap.put("searchWarehouse", SearchWarehouseHandler.class);
		this.handlerMap.put("searchPosition", SearchPositionHandler.class);
		this.handlerMap.put("getDoneTransBill", QueryTransBillHandler.class);
		this.handlerMap.put("getTransBillList",QueryTransBillListHandler.class);
		this.handlerMap.put("getTransBillListComfirm",QueryTransBillListComfirmHandler.class);
		this.handlerMap.put("toOtherOutTransBill",ToOtherOutTransBillHandler.class);
		this.handlerMap.put("toOtherInTransBill",ToOtherInTransBillHandler.class);
		this.handlerMap.put("getPickItems", GetPickItemByDmopksHandler.class);
		this.handlerMap.put("getEmptyCar", GetEmptyCarHandler.class);
		this.handlerMap.put("sendEmptyCar", SendEmptyCarHandler.class);
		this.handlerMap.put("sendFullCar", SendFullCarHandler.class);
		this.handlerMap.put("getTransBillInfo", GetTransBillInfoHandler.class);
	}
}